using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace DataLayerTest.Models.Mapping
{
    public class IndoorExercisePersonalMap : EntityTypeConfiguration<IndoorExercisePersonal>
    {
        public IndoorExercisePersonalMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Parameters)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("IndoorExercisePersonal");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.IdPlayer).HasColumnName("IdPlayer");
            this.Property(t => t.IdExerciseType).HasColumnName("IdExerciseType");
            this.Property(t => t.ActivationDate).HasColumnName("ActivationDate");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Difficulty).HasColumnName("Difficulty");
            this.Property(t => t.Time).HasColumnName("Time");
            this.Property(t => t.Repetitions).HasColumnName("Repetitions");
            this.Property(t => t.HoldingTime).HasColumnName("HoldingTime");
            this.Property(t => t.SpawningInterval).HasColumnName("SpawningInterval");
            this.Property(t => t.AliveTime).HasColumnName("AliveTime");
            this.Property(t => t.Parameters).HasColumnName("Parameters");

            // Relationships
            this.HasRequired(t => t.IndoorExerciseType)
                .WithMany(t => t.IndoorExercisePersonals)
                .HasForeignKey(d => d.IdExerciseType);
            this.HasRequired(t => t.Player)
                .WithMany(t => t.IndoorExercisePersonals)
                .HasForeignKey(d => d.IdPlayer);

        }
    }
}
